//
// Created by xili on 2024/8/24 11:36.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    int findPermutationDifference(string s, string t) {
        unordered_map<char, int> ump;
        int n = s.size();
        for (int i = 0; i < n; i++) {
            ump[s[i]] += i;
            ump[t[i]] -= i;
        }
        int ans = 0;
        for (auto &[c, v]: ump) {
            ans += abs(v);
        }
        return ans;
    }
};